﻿using System;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;
using System.Web;
using System.Collections.Generic;

namespace RedSand.Site.Models
{
    public class ActionInfo
    {
        public int ActionID { get; set; }
        public int ParentID { get; set; }
        public string Link { get; set; }
        public string Name { get; set; }
        public string CssClass { get; set; }
        public bool ShowOnMenu { get; set; }
    }
    public class ActionList
    {
        public static System.Collections.Generic.List<ActionInfo> Items
        {
            get
            {
                var list = (List<ActionInfo>)HttpContext.Current.Cache["ActionList"];
                if (list == null)
                {
                    list = AddActionToList();
                    HttpContext.Current.Cache["ActionList"] = list;
                }
                return list;
            }
        }
        private static List<ActionInfo> AddActionToList()
        {
            List<ActionInfo> list = new List<ActionInfo>();

            list.Add(new ActionInfo { ActionID = 9, ParentID = 0, ShowOnMenu = false, Name = "Administrator" });
            list.Add(new ActionInfo { ActionID = 91, ParentID = 9, ShowOnMenu = false, Name = "Admin page", Link="/admin" });

            //post
            list.Add(new ActionInfo { ActionID = 1, ParentID = 0, ShowOnMenu = false, Name = "Post", CssClass = "rs-icon-24 icon-text-documents" });
            list.Add(new ActionInfo { ActionID = 11, ParentID = 1, ShowOnMenu = false, Name = "Post edit", Link = "/edit/(.*).html" });
            list.Add(new ActionInfo { ActionID = 12, ParentID = 1, ShowOnMenu = false, Name = "Post delete", Link = "/delete/(.*).html" });
            
            //category
            list.Add(new ActionInfo { ActionID = 2, ParentID = 0, ShowOnMenu = true, Name = "Categories", CssClass = "rs-icon-24 icon-list-images" });
            //category
            list.Add(new ActionInfo { ActionID = 21, ParentID = 2, ShowOnMenu = true, Name = "Category manager", Link = "/category/manager" });
            list.Add(new ActionInfo { ActionID = 211, ParentID = 21, ShowOnMenu = false, Name = "Category create", Link = "/category/create/(.*)" });
            list.Add(new ActionInfo { ActionID = 212, ParentID = 21, ShowOnMenu = false, Name = "Category edit", Link = "/category/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 213, ParentID = 21, ShowOnMenu = false, Name = "Category delete", Link = "/category/delete/(.*)" });

            //user, role and action
            list.Add(new ActionInfo { ActionID = 3, ParentID = 0, ShowOnMenu = true, Name = "User and Role", CssClass = "rs-icon-24 icon-user-2" });
            //user
            list.Add(new ActionInfo { ActionID = 31, ParentID = 3, ShowOnMenu = true, Name = "User manager", Link = "/account/manager" });
            list.Add(new ActionInfo { ActionID = 311, ParentID = 31, ShowOnMenu = false, Name = "Account create", Link = "/account/create/(.*)" });
            list.Add(new ActionInfo { ActionID = 312, ParentID = 31, ShowOnMenu = false, Name = "Account edit", Link = "/account/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 313, ParentID = 31, ShowOnMenu = false, Name = "Account delete", Link = "/account/delete/(.*)" });
            //role
            list.Add(new ActionInfo { ActionID = 32, ParentID = 3, ShowOnMenu = true, Name = "Role manager", Link = "/role/manager" });
            list.Add(new ActionInfo { ActionID = 321, ParentID = 32, ShowOnMenu = false, Name = "Role create", Link = "/role/create/(.*)" });
            list.Add(new ActionInfo { ActionID = 322, ParentID = 32, ShowOnMenu = false, Name = "Role edit", Link = "/role/edit/(.*)" });
            list.Add(new ActionInfo { ActionID = 323, ParentID = 32, ShowOnMenu = false, Name = "Role delete", Link = "/role/delete/(.*)" });

            
            return list;
        }
    }
}
